var userpwd ;
var datepwd = "123";
var maxAttempts = 3;
var attemptCount = 0;

do {
    userpwd = prompt("请输入密码")
    if (userpwd === datepwd) {
        console.log("登录成功");
        break;
    } else {
        console.log("登录失败");
        attemptCount++;
        if (attemptCount < maxAttempts) {
            userpwd = prompt("请输入密码:"); // 假设使用 prompt 获取用户输入
        } else {
            console.log("超过最大尝试次数，登录失败");
            break;
        }
    }
} while (true);